﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Green.Utility
{
    public class JQueryUtilityCache
    {
        private Dictionary<Type, string> dict = new Dictionary<Type, string>();

        private static readonly JQueryUtilityCache _jQueryUtilityCache = new JQueryUtilityCache();

        public static JQueryUtilityCache Current
        {
            get
            {
                return _jQueryUtilityCache;
            }
        }

        public void AddScript(Type type, string script)
        {
            if (dict.Keys.Contains(type))
            {
                dict[type] = script;
            }
            else
            {
                dict.Add(type, script);
            }
        }

        public string GetScript(Type type)
        {
            if (dict.Keys.Contains(type))
            {
                return dict[type];
            }
            return string.Empty;
        }

        public bool Exists(Type type)
        {
            return dict.Keys.Contains(type);
        }
    }
}
